<?php 
class Download_model extends CI_Model {
	
	function __construct()
	{
		parent::__construct();
		$this->load->database();
		$this->load->library('session');
	}

	function get_years()
	{

		$sql = "SELECT DISTINCT date_format(start, '%Y') AS start FROM missions ORDER BY start asc";
		
		$query = $this->db->query($sql);

		$vysl = $query->result();

		$count = 0;
		$result = array();

		foreach($query->result() as $row)
		{
			$result[$count] = $row->start;
			$count = $count + 1;
		}

		{
			return $result;
		}
	}

	function get_missions($year)
	{

		$sql = "SELECT * FROM missions WHERE date_format(start,'%Y') = '".$year."' ORDER BY end asc";
		
		$query = $this->db->query($sql);

		$vysl = $query->result();

		$count = 0;
		$result = array();

		foreach($query->result() as $row)
		{
			$result[$count] = $row;
			$count = $count + 1;
		}

		{
			return $result;
		}
	}

	function get_content($sid)
	{
		$query = $this->db->where('id', $sid)->get('solutions');

		return $query->result()->content;
	}

	function get_attachments($sid)
	{
		$query = $this->db->where('sid', $sid)->get('attachments');

		return $query->result();
	}

	function get_links($sid)
	{
		$query = $this->db->where('sid', $sid)->get('videos');

		return $query->result();
	}

	function get_img($sid)
	{
		$query = $this->db->where('sid', $sid)->get('img');

		return $query->result();
	}

}